<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" ></meta>
    <title>详细内容</title>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap-datetimepicker.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/common.css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/picker.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/select2.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/beautify-time.css" type="text/css">
    <link rel="stylesheet" href="${assets}/css/views/department/addDepartment.scss">

    <%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <script src="${frames}/laydate/laydate.dev.js"></script>
    <script src="${assets}/bootstrapValidator/js/bootstrapValidator.js"></script>
    <script src="${assets}/bootstrapValidator/js/language/zh_CN.js"></script
    <link rel="stylesheet" href="${assets}/css/views/department/addDepartment.css">
    <script src="${newframe}/js/select2.full.zh.js"></script>
    <style>
        *{
            padding:0;
            list-style: none;
            text-decoration: none;
            font-weight:100;
            font-family:"微软雅黑";
        }
        body{
            height:auto;
        }
        span,label{
            font:15px/25px 微软雅黑;
            display:inline-block;
        }
        h1{
            font-family: MicrosoftYaHei;
            font-size: 20px;
            font-weight: normal;
            color: #2a3137;
            margin-bottom: 26px;
            float: left;
        }
        b{
            font-weight:600 !important;
            color:black;
            line-height:60px !important;
        }
        body{
            margin-left:15px;
        }
        h4{
            font:22px/34px 微软雅黑;
            color:black;
        }
        h3{
            font:22px/22px 微软雅黑;
            margin-top:0px;
            color:black;
            margin-bottom:20px;
        }
        body{
            width:768px;
            margin:0 auto;
            overflow:hidden;
        }
        /* 第二部分 最后检验 信息 */
        .illness{
            width:95%;
            overflow:hidden;
        }
        .illness h3{
            display: inline-block;
            margin-top:15px;
        }
        .illness a{
            width:8%;
            background-color: #35acfd;
            color:white;
            text-align:center;
            display:inline-block;
            line-height:150%;
            border-radius: 10px;
        }
        .feritin{
            margin:15px 0 15px 10px;
        }
        .feritin label{
            font:15px/44px 微软雅黑;
            color:#666666;
        }
        .feritin div:nth-child(1) .types{
            width:15%;
            height:30px;
        }
        .feritin div:nth-child(1) .types label{
            margin-left:20px;
        }
        .feritin div:nth-child(2) .ill{
            width:28%;
            height:30px;
        }
        .feritin div:nth-child(2) .ill label{
            margin-left:15%;
        }
        .feritin div:nth-child(3) .live{
            width:40%;
            vertical-align: middle;
            height:40px;
        }
        .feritin div:nth-child(3) .live input{
            margin-left:10%;
        }
        .feritin div:nth-child(3) .live label{
            margin-left:3%;
            margin-right:3%;
            vertical-align: middle;
        }
        .feritin div:nth-child(3) .live label{
            margin:0 3%;
            vertical-align: middle;
        }
        .text{
            width:100%;
        }
        .title{
            line-height:25px;
            margin-bottom: 5px;
            font-size:16px;
            color:#666666;
            margin-left:10px;
            width:18%;
        }
        .title1{
            line-height:25px;
            font-size:16px;
            color:#666666;
            margin-left:10px;
            margin-top:5px;
        }
        .text_content{
            margin:20px 0;
            margin-left:14px;
        }
        .text_content div{
            width:48%;
            text-align: left;
            display: inline-block;
        }
        .text_number{
            color:#666666;
            margin-left:20px;
        }
        .text_number span{
            margin-left:20px;
        }
        /*thead hr{*/
        /*border-top: none !important;*/
        /*border-bottom: none !important;*/
        .news{
            width:95%;
        }
        .feritin input{
            width:20px;
            height:20px;
            background:white;
            vertical-align: middle;
            margin-bottom:7px;
            display:inline-block !important;
        }
        input[type=checkbox] {
            -webkit-appearance: none;
            border-radius:5px;
            border:1px solid #9e9e9e;
        }
        input[type=checkbox]:checked{
            background-image: url('../assets/images/radio.png');
            background-size:100% 100%
        }
        input[type=radio] {
            -webkit-appearance: none;
            border-radius:50%;
            background-image: url('../assets/images/nocheck.png');
            background-size:100% 100%
        }
        input[type=radio]:checked{
            background-image: url('../assets/images/checkout.png');
            background-size:100% 100%
        }
        .ill1{
            width:18%;
            display:inline-block;
        }
        .test{
            width:100%;
            overflow:hidden;
        }
        .test p{
            width:100%;
            line-height:100px;
            font-size:15px;
            text-align:center;
        }
        #change{
            position:fixed;
            bottom:16px;
            right:16px;
        }
        .change{
            position:fixed;
            top:78%;
            width:100%;
        }
        .btn{
            width:100px;
            line-height: 15px;
            background: #35acfd;
            color: white;
            margin-top:15px;
        }
        .modal-footer{
            width:255px;
            margin:0 auto;
        }
        #keep{
            background:#35acfd !important;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>高血压信息</h1>
    </div>
    <div class="test">
        <div>
            <span style="width:5px;padding-bottom:25px;background-color:#35acfd;display:inline-block;vertical-align:middle"></span>
            <span class="title">高血压信息</span>
        </div>
        <div class="feritin">
            <div>
                <span class="title">最高血压值</span>
                    <span style="width:20%">
                        <span >收缩压</span>
                        <input type="text" class="form-control" id="highestBpSystolic" onkeyup="value=value.replace(/[^\d.]/g,'')" style="width:55px;height:25px;" placeholder="">
                        <span>mmHg</span>
                    </span>
                    <span style="width:20%">
                        <span >舒张压</span>
                        <input type="text" class="form-control" id="highestBpDiastolic" onkeyup="value=value.replace(/[^\d.]/g,'')" style="width:55px;height:25px;" placeholder="">
                        <span>mmHg</span>
                    </span>

                <b id="bpTestPlace">
                    <span style="width:10%">
                        <input type="radio" value="1" name="bpTestPlace" id="bpTestPlace1">
                        <label for="bpTestPlace1">诊室</label>
                    </span>
                    <span style="width:12%">
                        <input type="radio" value="2" name="bpTestPlace" id="bpTestPlace2">
                        <label for="bpTestPlace2">家庭自测</label>
                    </span>
                </b>
            </div>
            <div>
                <span class="title">高血压类型</span>
                <b id="classtype">
                    <span class="types">
                        <input type="radio" value="0" name="class" id="t1">
                        <label for="t1">Ⅰ级</label>
                    </span>
                    <span class="types">
                        <input type="radio" value="1" name="class" id="t2">
                        <label for="t2">Ⅱ级</label>
                    </span>
                    <span class="types">
                        <input type="radio" value="2" name="class" id="t3">
                        <label for="t3">Ⅲ级</label>
                    </span>
                </b>
            </div>
            <div>
                <span class="title" style="margin-top:7px;">高血压并发症</span>
                <div style="display: inline-block; vertical-align: top; width: 80%;" id="bgillness">
                    <span class="ill">
                        <input type="checkbox" value="" id="r1"/>
                        <label for="r1">脑血管疾病</label>
                    </span>
                        <span class="ill">
                        <input type="checkbox" value="" id="r2" />
                        <label for="r2">心脏疾病</label>
                    </span>
                        <span class="ill">
                        <input type="checkbox" value="" id="r3" />
                        <label for="r3">肾脏疾病</label>
                    </span>
                        <span class="ill">
                        <input type="checkbox" value="" id="r4" />
                        <label for="r4">血管疾病</label>
                    </span>
                        <span class="ill"  style="width:40% !important;">
                        <input type="checkbox" value="" id="r5" />
                        <label for="r5">重度高血压视网膜病变</label>
                    </span>
                </div>
            </div>
            <div style="margin-top:10px;">
                <span class="title" style="margin-top:17px;">生活习惯</span>
                <div style="display: inline-block; vertical-align: top; width:80%;">
                    <span class="live">
                        <span>吸烟情况</span>
                        <b id="smoke">
                           <input type="radio" value="" name="type" id="s1">
                            <label for="s1">是</label>
                            <input type="radio" value="" name="type" id="s2">
                            <label for="s2">否</label>
                        </b>
                    </span>
                        <span class="live">
                        <span>烟酒情况</span>
                        <b id="drink">
                            <input type="radio" value="" name="yan" id="z1">
                            <label for="z1">是</label>
                            <input type="radio" value="" name="yan" id="z2">
                            <label for="z2">否</label>
                        </b>
                    </span>
                        <span class="live">
                        <span>体力活动</span>
                        <b id="physical">
                            <input type="radio" value="" name="active" id="y1">
                            <label for="y1">有</label>
                            <input type="radio" value="" name="active" id="y2">
                            <label for="y2">否</label>
                        </b>
                    </span>
                </div>
            </div>
        </div>
    </div>
    <div class="change">
        <div class="form-group submitBtn" style="text-align: center ">
            <button type="button" class="btn" data-dismiss="modal" id="closeModalButt" onclick="closeFrame()">
                关闭
            </button>
            <button type="submit" class="btn" id="keep"  onclick="keep()" style="margin-left:20px;">保存</button>
        </div>
    </div>

    <script>
        function closeFrame() {
            window.parent.simpleCloseModal();
        }
        // 初始化显示
        function check(i){
            // 判断血压并发症
            var Input = $("#bgillness input");
            $(Input[i-1]).attr("checked","checked")
        }
        $(function(){
            // 血压等级
            var aa = '${entity.bpType}';
            if( aa === '' ){

            }else if(aa === '2'){
                $("#t2").attr("checked","checked");
            }else if( aa === '3' ){
                $("#t3").attr("checked","checked");
            }else if( aa === "1" ){
                $("#t1").attr("checked","checked");
            }

            // 最高血压值
            // 最高血压值（高压）（收缩压）
            var highestBpSystolic = '${entity.highestBpSystolic}';
            if(highestBpSystolic == null) {
                $("#highestBpSystolic").val(0);
            } else {
                $("#highestBpSystolic").val(highestBpSystolic);
            }
            // 最高血压值（低压）（舒张压）
            var highestBpDiastolic = '${entity.highestBpDiastolic}';
            if(highestBpDiastolic == null) {
                $("#highestBpDiastolic").val(0);
            } else {
                $("#highestBpDiastolic").val(highestBpDiastolic);
            }

            // 最高血压值测量地点
            var bpTestPlace = '${entity.bpTestPlace}';
            if( bpTestPlace === '' ){

            }else if(bpTestPlace === '1'){
                $("#bpTestPlace1").attr("checked","checked");
            }else if(bpTestPlace === '2' ){
                $("#bpTestPlace2").attr("checked","checked");
            }

            // 是否吸烟
            var smoke = '${entity.smoke}';
            if( smoke === '' ){

            }else if(smoke === '1'){
                $("#s1").attr("checked","checked");
            }else if( smoke === '2' ){
                $("#s2").attr("checked","checked");
            }
            // 是否体力劳动
            var physical = '${entity.physical}';
            if( physical === '' ){

            }else if(physical === '1'){
                $("#y1").attr("checked","checked");
            }else if( physical === '2' ){
                $("#y2").attr("checked","checked");
            }
            // 是否饮酒
            var drink = '${entity.drink}';
            if( drink === '' ){

            }else if(drink === '1'){
                $("#z1").attr("checked","checked");
            }else if( drink === '2' ){
                $("#z2").attr("checked","checked");
            }
            // 判断并发症
            var checkbs = '${entity.bpComplication}'
//            console.log(checkbs[0])
            if( checkbs === '' ){
                // 没有选择
            } else if( checkbs.length === 1 ){
                // 当只选择一种并发症
                check(checkbs)
            }else if( checkbs.length === 3 ){
                // 当选择两种并发症
                check(checkbs[0])
                check(checkbs[2])
            }else if( checkbs.length === 5 ){
                // 当选择三种并发症
                check(checkbs[0])
                check(checkbs[2])
                check(checkbs[4])
            }else if( checkbs.length === 7 ){
                // 当选择四种并发症
                check(checkbs[0])
                check(checkbs[2])
                check(checkbs[4])
                check(checkbs[6])
            }else if( checkbs.length === 9 ){
                // 当选择五种并发症
                check(checkbs[0])
                check(checkbs[2])
                check(checkbs[4])
                check(checkbs[6])
                check(checkbs[8])
            }
        })
        function keep(){
            // 获取当前url
            var url = location.search.split('?')
            var href = url[1].split('&')[1].split('=')[1]
            var type = url[1].split('&')[2].split('=')[1]
            //  获取对应数据
            // 获取当前选中的数据
            // 高血压并发症
            var bpComplication = $("#bgillness input");
            var bpComplicationjson = [];
            for( var a = 0 ; a < bpComplication.length; a++ ){
                if( bpComplication[a].checked ){
                    bpComplicationjson.push(a+1)
                }
            }
            bpComp = String(bpComplicationjson)
            // 血压等级
            var classtype = $("#classtype input");
            var classtypeComp = [];
            for( var a = 0 ; a < classtype.length; a++ ){
                if( classtype[a].checked ){
                    classtypeComp.push(a+1)
                }
            }
            var bpType = String(classtypeComp)

            // 是否抽烟
            var smokeComp = $("#smoke input");
            var smokejson = [];
            for( var a = 0 ; a < smokeComp.length; a++ ){
                if( smokeComp[a].checked ){
                    smokejson.push(a+1)
                }
            }
            var smoke = ''
            if( smokejson.length === 0 ){
                smoke = ''
            }else{
                smoke = parseInt(smokejson)
            }
            // 是否饮酒
            var drinkComp = $("#drink input");
            var drinkjson = [];
            for( var a = 0 ; a < drinkComp.length; a++ ){
                if( drinkComp[a].checked ){
                    drinkjson.push(a+1)
                }
            }
            var drink = ''
            if( drinkjson.length === 0 ){
                drink = ''
            }else{
                drink = parseInt(drinkjson)
            }
            // 是否体力劳动
            var physicalComp = $("#physical input");
            var physicaljson = [];
            for( var a = 0 ; a < physicalComp.length; a++ ){
                if( physicalComp[a].checked ){
                    physicaljson.push(a+1)
                }
            }
            var physical = ''
            if( physicaljson.length === 0 ){
                physical = ''
            }else{
                physical = parseInt(physicaljson)
            }

            // debugger;
            var highestBpDiastolic = $("#highestBpDiastolic").val();
            var highestBpSystolic = $("#highestBpSystolic").val();

            // 血压等级
            var bpTestPlace = $("#bpTestPlace input");
            var bpTestPlaceComp = [];
            for( var a = 0 ; a < bpTestPlace.length; a++ ){
                if( bpTestPlace[a].checked ){
                    bpTestPlaceComp.push(a+1)
                }
            }
            var bpTestPlace = String(bpTestPlaceComp);

            var idcard = '${entity.idcard}';
            $.ajax({
                url:"${URL_PATIENT_UPDATEBPINFO}",
                dataType:"json",
                type:"post",
                data:{
                    id:${entity.id},
                    bpType:bpType,
                    bpComplication:bpComp,
                    smoke:smoke,
                    drink:drink,
                    physical:physical,
                    bpTestPlace: bpTestPlace,
                    highestBpDiastolic: highestBpDiastolic,
                    highestBpSystolic: highestBpSystolic
                },
                success:function(data){
                    if( data.success ){
                        // 刷新当前页面
                        parent.showSrc('${URL_PATIENT_TOARCHIVES}?idCard=' + idcard+'&diseasesType='+href+'&type='+type)
                        window.parent.simpleCloseModal();
                    }
                }
            })
        }
    </script>
</body>
</html>